<template>
  <view class="login-container">
      <uni-icons type="contact-filled" size="100" color="#AFAFAF"></uni-icons>
      <button type="primary" class="btn-login" @click="getUserProfile">一键登录</button>
      <view class="tips-text">登录后享更多权益</view>
    </view>
  
</template>

<script>
  import {mapMutations,mapState} from 'vuex'
import { getToken } from '../../api/request';
  export default {
    name:"myLogin",
    data() {
      return {
        query: {
          code: '',
          encryptedData: '',
          iv: '',
          rawData: '',
          signature: ''
        }
      };
    },
    computed:{
      ...mapState('my_user',['userinfo'])
    },
    methods:{
      ...mapMutations('my_user',['updateUserInfo','updateToken']),
      // 获取用户信息
       async getUserProfile(e){
        const [erro, success] = await uni.getUserProfile({desc: '业务需要'})
        if(success.errMsg !== "getUserProfile:ok") return
        this.updateUserInfo(success.userInfo)    
        // this.query.encryptedData = success.encryptedData
        // this.query.iv = success.iv
        // this.query.rawData = success.rawData
        // this.query.signature = success.signature
        // const [err, res] = await uni.login().catch(err => err)
        // this.query.code = res.code
        // console.log(this.query);        
        // const {data:result} = await uni.$http.post('users/wxlogin', this.query)
        // console.log(result);
        this.updateToken("Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1aWQiOjIzLCJpYXQiOjE1NjQ3MzAwNzksImV4cCI6MTAwMTU2NDczMDA3OH0.YPt-XeLnjV-_1ITaXGY2FhxmCe4NvXuRnRB8OMCfnPo")
        }
        
      }
    }
</script>

<style lang="scss">
.login-container {
  // 登录盒子的样式
  height: 750rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: #f8f8f8;
  position: relative;
  overflow: hidden;

  // 绘制登录盒子底部的半椭圆造型
  &::after {
    content: ' ';
    display: block;
    position: absolute;
    width: 100%;
    height: 40px;
    left: 0;
    bottom: 0;
    background-color: white;
    border-radius: 100%;
    transform: translateY(50%);
  }

  // 登录按钮的样式
  .btn-login {
    width: 90%;
    border-radius: 100px;
    margin: 15px 0;
    background-color: #00aa00;
  }

  // 按钮下方提示消息的样式
  .tips-text {
    font-size: 12px;
    color: gray;
  }
}

</style>